# 多态
class Person:
    def __init__(self, name):
        self.__name = name

    def feed_pet(self, pet):
        # 判断pet是不是Pet得对象，或者pet是不是Pet子类的对象
        if isinstance(pet, Pet):

            print("{}喜欢喂养宠物{}，{}".format(self.__name, pet.role, pet))
        else:
            print("不是宠物严禁饲养！")

    pass


class Pet:
    role = 'Pet'

    def __init__(self, nickname, age):
        self.__nickname = nickname
        self.__age = age

    def show(self):
        print("昵称：{}，年龄{}".format(self.__nickname, self.__age))

    def __str__(self):
        return "昵称：{}，年龄{}".format(self.__nickname, self.__age)


class Cat(Pet):
    role = '猫'

    def catch_mouse(self):
        print("抓老鼠")


class Dog(Pet):
    role = '狗'

    def watch_house(self):
        print("看家护院")


class Tiger:
    def eat(self):
        print("太可怕了，可以吃人")


c = Cat("小花", 3)
d = Dog("小黄", 4)
p = Person("张三")
p.feed_pet(c)
p.feed_pet(d)

t = Tiger()
p.feed_pet(t)
